public class Solution
{
    public static String get(String pre, String mid){
        if(pre.length() == 1 || pre.length() == 0){
            return pre;
        }

        String root = String.valueOf(pre.charAt(0));

        String mid_left_child = "";
        String mid_right_child = "";

        if(mid.startsWith(root)){
            mid_right_child = mid.split(root)[1];
        }else if(mid.endsWith(root)){
            mid_left_child = mid.split(root)[0];
        }else{
            mid_left_child = mid.split(root)[0];
            mid_right_child = mid.split(root)[1];
        }

        String pre_left_child = pre.substring(1, mid_left_child.length()+1);
        String pre_right_child = pre.substring(mid_left_child.length()+1, pre.length());

        return get(pre_left_child, mid_left_child) + get(pre_right_child, mid_right_child) + root;
    }


    public static void main(String[] args) {
        String[] input = args[0].split("__");
        String pre = input[0];
        String mid = input[1];

        System.out.println(get(pre, mid));
    }
}
